
package std.io


@!APILevel[
    since: "22"
]
public class BufferedInputStream<T> <: InputStream where T <: InputStream {
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(input: T)
    
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(input: T, capacity: Int64)
    
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(input: T, buffer: Array<Byte>)
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func read(buffer: Array<Byte>): Int64
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func readByte(): ?Byte
    
    @!APILevel[
        since: "22"
    ]
    public func reset(input: T): Unit
}

extend<T> BufferedInputStream<T> <: Resource where T <: Resource {
    @!APILevel[
        since: "22"
    ]
    public func close(): Unit
    
    @!APILevel[
        since: "22"
    ]
    public func isClosed(): Bool
}

extend<T> BufferedInputStream<T> <: Seekable where T <: Seekable {
    @!APILevel[
        since: "22"
    ]
    public func seek(sp: SeekPosition): Int64
    
    @!APILevel[
        since: "22"
    ]
    public prop position: Int64
    
    @!APILevel[
        since: "22"
    ]
    public prop remainLength: Int64
    
    @!APILevel[
        since: "22"
    ]
    public prop length: Int64
}

@!APILevel[
    since: "22"
]
public class BufferedOutputStream<T> <: OutputStream where T <: OutputStream {
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(output: T)
    
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(output: T, buffer: Array<Byte>)
    
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(output: T, capacity: Int64)
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(buffer: Array<Byte>): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeByte(v: Byte): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func flush(): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func reset(output: T): Unit
}

extend<T> BufferedOutputStream<T> <: Resource where T <: Resource {
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func close(): Unit
    
    @!APILevel[
        since: "22"
    ]
    public func isClosed(): Bool
}

extend<T> BufferedOutputStream<T> <: Seekable where T <: Seekable {
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func seek(sp: SeekPosition): Int64
    
    @!APILevel[
        since: "22"
    ]
    public prop position: Int64
    
    @!APILevel[
        since: "22"
    ]
    public prop remainLength: Int64
    
    @!APILevel[
        since: "22"
    ]
    public prop length: Int64
}

@!APILevel[
    since: "22"
]
public class ByteBuffer <: IOStream & Seekable {
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init()
    
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(capacity: Int64)
    
    @!APILevel[
        since: "22"
    ]
    public init(source: Array<Byte>)
    
    @!APILevel[
        since: "22"
    ]
    public prop capacity: Int64
    
    @!APILevel[
        since: "22"
    ]
    public func clone(): ByteBuffer
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func clear(): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func bytes(): Array<Byte>
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func read(buffer: Array<Byte>): Int64
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func readByte(): ?Byte
    
    /**
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @OverflowWrapping
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(buffer: Array<Byte>): Unit
    
    /**
    * @throws IllegalArgumentException
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    */
    @OverflowWrapping
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeByte(v: Byte): Unit
    
    /**
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func setLength(length: Int64): Unit
    
    /**
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func reserve(addition: Int64): Unit
    
    /**
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func seek(sp: SeekPosition): Int64
}

@!APILevel[
    since: "22"
]
public class ChainedInputStream<T> <: InputStream where T <: InputStream {
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(input: Array<T>)
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func read(buffer: Array<Byte>): Int64
}

@!APILevel[
    since: "22"
]
public class ContentFormatException <: Exception {
    @!APILevel[
        since: "22"
    ]
    public init()
    
    @!APILevel[
        since: "22"
    ]
    public init(message: String)
}

@!APILevel[
    since: "22"
]
public open class IOException <: Exception {
    @!APILevel[
        since: "22"
    ]
    public init()
    
    @!APILevel[
        since: "22"
    ]
    public init(message: String)
}

@!APILevel[
    since: "22"
]
public enum SeekPosition {
    @!APILevel[
        since: "22"
    ]
    Current(Int64) |
    @!APILevel[
        since: "22"
    ]
    Begin(Int64) |
    @!APILevel[
        since: "22"
    ]
    End(Int64)
}

/**
* @throws IllegalArgumentException
* @throws ContentFormatException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func readString<T>(from: T): String where T <: InputStream & Seekable

/**
* @throws IllegalArgumentException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public unsafe func readStringUnchecked<T>(from: T): String where T <: InputStream & Seekable

/**
* @throws OverflowException
* @throws IndexOutOfBoundsException
* @throws IllegalArgumentException
*/
@OverflowWrapping
@!APILevel[
    since: "22",
    throwexception: true
]
public func readToEnd<T>(from: T): Array<Byte> where T <: InputStream & Seekable

/**
* @throws IndexOutOfBoundsException
*/
@!APILevel[
    since: "22",
    throwexception: true
]
public func copy(from: InputStream, to!: OutputStream): Int64

@!APILevel[
    since: "22"
]
public class MultiOutputStream<T> <: OutputStream where T <: OutputStream {
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(output: Array<T>)
    
    @!APILevel[
        since: "22"
    ]
    public func write(buffer: Array<Byte>): Unit
    
    @!APILevel[
        since: "22"
    ]
    public func flush(): Unit
}

@!APILevel[
    since: "22"
]
public interface InputStream {
    @!APILevel[
        since: "22"
    ]
    func read(buffer: Array<Byte>): Int64
}

@!APILevel[
    since: "22"
]
public interface OutputStream {
    @!APILevel[
        since: "22"
    ]
    func write(buffer: Array<Byte>): Unit
    
    @!APILevel[
        since: "22"
    ]
    func flush(): Unit
}

@!APILevel[
    since: "22"
]
public interface IOStream <: InputStream & OutputStream {
}

@!APILevel[
    since: "22"
]
public interface Seekable {
    @!APILevel[
        since: "22"
    ]
    func seek(sp: SeekPosition): Int64
    
    @!APILevel[
        since: "22"
    ]
    prop position: Int64
    
    @!APILevel[
        since: "22"
    ]
    prop remainLength: Int64
    
    @!APILevel[
        since: "22"
    ]
    prop length: Int64
}

@!APILevel[
    since: "22"
]
public class StringReader<T> where T <: InputStream {
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(input: T)
    
    /**
    * @throws IllegalArgumentException
    * @throws ContentFormatException
    * @throws IndexOutOfBoundsException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func read(): ?Rune
    
    @!APILevel[
        since: "22"
    ]
    public func runes(): Iterator<Rune>
    
    /**
    * @throws IllegalArgumentException
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws ContentFormatException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func readln(): Option<String>
    
    @!APILevel[
        since: "22"
    ]
    public func lines(): Iterator<String>
    
    /**
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    * @throws ContentFormatException
    */
    @Frozen
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func readToEnd(): String
    
    /**
    * @throws ContentFormatException
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func readUntil(v: Rune): Option<String>
    
    /**
    * @throws ContentFormatException
    * @throws OverflowException
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func readUntil(predicate: (Rune) -> Bool): Option<String>
}

extend<T> StringReader<T> <: Resource where T <: Resource {
    @!APILevel[
        since: "22"
    ]
    public func close(): Unit
    
    @!APILevel[
        since: "22"
    ]
    public func isClosed(): Bool
}

extend<T> StringReader<T> <: Seekable where T <: Seekable {
    @!APILevel[
        since: "22"
    ]
    public func seek(sp: SeekPosition): Int64
    
    @!APILevel[
        since: "22"
    ]
    public prop position: Int64
}

@!APILevel[
    since: "22"
]
public class StringWriter<T> where T <: OutputStream {
    /**
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public init(output: T)
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func flush(): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: String): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write<T>(v: T): Unit where T <: ToString
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Bool): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Int8): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Int16): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Int32): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Int64): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: UInt8): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: UInt16): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: UInt32): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: UInt64): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Float16): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Float32): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IOException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Float64): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func write(v: Rune): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(): Unit
    
    /**
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: String): Unit
    
    /**
    * @throws IllegalArgumentException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln<T>(v: T): Unit where T <: ToString
    
    /**
    * @throws IndexOutOfBoundsException
    * @throws IllegalArgumentException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Bool): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Int8): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Int16): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Int32): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Int64): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: UInt8): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: UInt16): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: UInt32): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: UInt64): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Float16): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Float32): Unit
    
    /**
    * @throws IOException
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Float64): Unit
    
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func writeln(v: Rune): Unit
}

extend<T> StringWriter<T> <: Resource where T <: Resource {
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func close(): Unit
    
    @!APILevel[
        since: "22"
    ]
    public func isClosed(): Bool
}

extend<T> StringWriter<T> <: Seekable where T <: Seekable {
    /**
    * @throws IndexOutOfBoundsException
    */
    @!APILevel[
        since: "22",
        throwexception: true
    ]
    public func seek(sp: SeekPosition): Int64
}

